﻿<BadHabit_Factory_Controls:GenericPanel
    x:Class="BadHabit.Factory.Controls.TailPanel"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:BadHabit_Factory_Controls="clr-namespace:BadHabit.Factory.Controls"
    xmlns:BadHabit_Factory_Converters="clr-namespace:BadHabit.Factory.Converters"
    xmlns:BadHabit_WPFTools="clr-namespace:BadHabit.WPFTools;assembly=BadHabit.WPFTools"                    
    xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
    
    xmlns:props="clr-namespace:BadHabit.Factory.Windows.Properties"
    
    HorizontalAlignment="Stretch"  VerticalAlignment="Stretch"
    MinWidth="400" MinHeight="400">

    <BadHabit_Factory_Controls:GenericPanel.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Save" CanExecute="Save_CanExecute" Executed="Save_Executed"/>
    </BadHabit_Factory_Controls:GenericPanel.CommandBindings>


    <BadHabit_Factory_Controls:GenericPanel.Resources>


        <CollectionViewSource x:Key="BacklogItemList" Source="{Binding BacklogItem}">
            <CollectionViewSource.SortDescriptions>
                <scm:SortDescription PropertyName="BacklogItemNumber" Direction="Ascending"  />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>



  

        <DataTemplate x:Key="BacklogItemTemplate" >
            
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="20"/>
                            <ColumnDefinition Width="20"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="10"/>
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Style="{StaticResource BacklogItemStatusImage}" VerticalAlignment="Top" HorizontalAlignment="Center" DataContext="{Binding Status}" Width="16" Height="16"/>
                        <TextBlock Grid.Column="1" Text="{Binding BacklogItemNumber}" TextAlignment="Right" VerticalAlignment="Top" Margin="0,0,5,0"/>
                        <TextBlock Grid.Column="2" Text="{Binding Title}" TextWrapping="Wrap"/>
                        <TextBlock Grid.Column="3" Text="{Binding SprintNumber}" HorizontalAlignment="Right" FontSize="8" VerticalAlignment="Top"/>
                    </Grid>
            
        </DataTemplate>
        
        <DataTemplate x:Key="ImpactedItemsItemTemplate">            
                <Grid HorizontalAlignment="Stretch" Margin="0,3,0,3" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="24"/>
                        <ColumnDefinition Width="20"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Image Grid.Column="0" DataContext="{Binding Status}" Style="{StaticResource BacklogItemStatusImage}" VerticalAlignment="Top" Width="16" Height="16"/>
                    <TextBlock Grid.Column="1" Text="{Binding BacklogItemNumber}" TextWrapping="Wrap"  VerticalAlignment="Top"/>
                    <TextBlock Grid.Column="2" Text="{Binding Title}" TextWrapping="Wrap" ToolTip="{Binding ProjectName, StringFormat={x:Static props:Resources.project_N}}"/>
                </Grid>            
        </DataTemplate>

    </BadHabit_Factory_Controls:GenericPanel.Resources>
    
    
    <Grid x:Name="ContentPanel" VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="270"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="200"/>
        </Grid.ColumnDefinitions>

        <DockPanel Grid.Row="0" Grid.ColumnSpan="3" >
            <ToolBar x:Name="Toolbar" DockPanel.Dock="Left" ToolBarTray.IsLocked="True" Height="60" >

                <TextBlock VerticalAlignment="Center" Style="{StaticResource Label}" Text="{x:Static props:Resources.Search}" />
            <TextBox x:Name="searchTextBox" Width="150" Style="{StaticResource FilterTextBox}" TextChanged="searchTextBox_TextChanged" />

            <TextBlock x:Name="taskFilterLabel"
                       Foreground="{StaticResource DarkTextBrush}"
                       Margin="5,0,0,0" Visibility="Hidden" Height="40" Width="40" TextAlignment="Center" Padding="0,15,0,0">
                <TextBlock.Background>
                    <ImageBrush ImageSource="/Images/postit.gif" TileMode="None"/>
                </TextBlock.Background>
                <TextBlock.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="{x:Static props:Resources.Clear_task_filter}" Click="cleanFilterMenuItem_Click" />
                    </ContextMenu>
                </TextBlock.ContextMenu>
            </TextBlock>

        </ToolBar>
            <Button
                        x:Name="commitButton"
                        DockPanel.Dock="Right"
                        Style="{StaticResource CommitButton}"
                        Command="ApplicationCommands.Save"
                        HorizontalAlignment="Right" 
                        Margin="5" />
        </DockPanel>



        <ListBox
                x:Name="backlogListView"                           
                ItemContainerStyle="{StaticResource HorizontalDividedListBoxItem}"
                ItemTemplate="{StaticResource BacklogItemTemplate}"                                   
                Grid.Column="0" Grid.Row="1"
                HorizontalContentAlignment="Stretch" VerticalAlignment="Stretch"  
                ScrollViewer.HorizontalScrollBarVisibility="Disabled"                     
                IsSynchronizedWithCurrentItem="True"
                ItemsSource="{Binding Source={StaticResource BacklogItemList}}"
                SelectionChanged="backlogListView_SelectionChanged"
                SelectionMode="Single" 
                SnapsToDevicePixels="True"                                           
                BorderThickness="0,0,0,0"    
                Background="Transparent"/>
        
        <Grid Grid.Column="1" Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="250"/>
            </Grid.RowDefinitions>
            
            <Border             
                Grid.Row="0"                        
                Style="{StaticResource RoundBorder}">
                <Grid Margin="3">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                                        
                    <Border Grid.Row="0"  Background="{StaticResource LightStrongBrush}" CornerRadius="3,3,0,0" BorderThickness="0" Padding="3">
                        <TextBlock Foreground="{StaticResource DarkTextBrush}" Text="{x:Static props:Resources.Tailed_Artifacts}"/>
                    </Border>
                    
                    <BadHabit_Factory_Controls:ArtifactListBox
                        Grid.Row="1"
                        x:Name="artifactsListBox"          
                        Project="{Binding Project[0]}"                        
                        ScrollViewer.VerticalScrollBarVisibility="Auto"     
                        ScrollViewer.HorizontalScrollBarVisibility="Disabled"                        
                        VerticalContentAlignment="Top"
                        SelectionChanged="artifactsListBox_SelectionChanged"/>
          
                </Grid>

            </Border>


            <Border             
                Margin="3,3,0,0"
                Grid.Row="1"                   
                Style="{StaticResource RoundBorder}">

                <Grid Margin="3">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>                    
                    <Border Grid.Row="0"  Background="{StaticResource LightStrongBrush}" CornerRadius="3,3,0,0" BorderThickness="0" Padding="3">
                        <TextBlock Foreground="{StaticResource DarkTextBrush}" Text="{x:Static props:Resources.Releated_Tasks}"/>
                    </Border>

                    <ListView
                        Grid.Row="1" 
                        x:Name="taskListView"
                        ScrollViewer.VerticalScrollBarVisibility="Auto"     
                        ScrollViewer.HorizontalScrollBarVisibility="Auto"
                        BorderThickness="0"
                        Foreground="Black"                        
                        
                        VerticalContentAlignment="Top">

                        <ListView.View>
                            <GridView AllowsColumnReorder="True" >
                                
                                                                
                                <GridViewColumn Width="32" >
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <Image Source="/Images/TaskType/16x16/PROJECT_TASK.png" Width="16" Height="16" Stretch="Uniform"/>                                            
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="{x:Static props:Resources.Id}" DisplayMemberBinding="{Binding Path=TaskId, StringFormat='{}{0:00000}'}" Width="60"  />
                                <GridViewColumn Header="{x:Static props:Resources.Task}" DisplayMemberBinding="{Binding Path=TaskName}" Width="200"  />
                                <GridViewColumn Header="{x:Static props:Resources.Assignee}" DisplayMemberBinding="{Binding Path=TaskAssignee}" Width="150"/>
                                <GridViewColumn Header="{x:Static props:Resources.Start}" DisplayMemberBinding="{Binding Path=Start,StringFormat='{}{0:d}'}" Width="100" />                                    
                                <GridViewColumn Header="{x:Static props:Resources.Finish}" DisplayMemberBinding="{Binding Path=Finish,StringFormat='{}{0:d}'}" Width="100"/>
                                
                            </GridView>
                        </ListView.View>

                    </ListView>
               
                </Grid>
                
            </Border>
            
            <GridSplitter Grid.Row="0" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Height="1" Background="Transparent"/>
            
        </Grid>

     
        <Border 
            Grid.Column="2" Grid.Row="1"            
            Style="{StaticResource RoundBorder}">
            <Grid Margin="3">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Border Grid.Row="0"  Background="{StaticResource LightStrongBrush}" CornerRadius="3,3,0,0" BorderThickness="0" Padding="3">
                    <TextBlock Foreground="{StaticResource DarkTextBrush}" Text="{x:Static props:Resources.Impacted_Items}"/>
                </Border>
                <ListBox
                    Grid.Row="1"
                    x:Name="impactedItemsListBox"            
                    HorizontalAlignment="Stretch"
                    HorizontalContentAlignment="Stretch"
                    VerticalAlignment="Stretch"
                    ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                    BorderThickness="0"
                    
                    ItemTemplate="{StaticResource ImpactedItemsItemTemplate}"/>
                    
            </Grid>
            
        </Border>


        <GridSplitter Grid.Column="1" Grid.Row="1" Width="1" Background="Transparent"/>


    </Grid>





</BadHabit_Factory_Controls:GenericPanel>
